package com.cskaoyan.controller.wx.nj;


import com.cskaoyan.bean.wx.nj.CskaoyanmallOrderGoods;
import com.cskaoyan.service.wx.nj.WxOrderService;
import com.cskaoyan.vo.BaseRespVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("wx/order")
public class WXOrderController {

    @Autowired
    WxOrderService wxOrderService;



    @PostMapping("delete")
    public BaseRespVo delete(@RequestBody Map map){
        Integer orderId = (Integer) map.get("orderId");
        wxOrderService.deleteOrder(orderId);
        return BaseRespVo.ok();
    }

    @PostMapping("cancel")
    public BaseRespVo cancel(@RequestBody Map map){
        Integer orderId = (Integer) map.get("orderId");
        wxOrderService.cancelOrder(orderId);
        return BaseRespVo.ok();
    }

    @PostMapping("refund")
    public BaseRespVo refund(@RequestBody Map map){
        Integer orderId = (Integer) map.get("orderId");
        wxOrderService.refundOrder(orderId);
        return BaseRespVo.ok();
    }

    @PostMapping("confirm")
    public BaseRespVo confirm(@RequestBody Map map){
        Integer orderId = (Integer) map.get("orderId");
        wxOrderService.confirmOrder(orderId);
        return BaseRespVo.ok();
    }

    @RequestMapping("goods")
    public BaseRespVo goods(Integer orderId,Integer goodsId){
        CskaoyanmallOrderGoods orderGoods = wxOrderService.selectGoods(orderId,goodsId);
        return BaseRespVo.ok(orderGoods);
    }
}
